# $Id: PKGBUILD 86219 2013-03-13 13:38:07Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=(lua-zlib lua51-zlib)
pkgbase=lua-zlib
pkgver=0.2
pkgrel=4
_gitver=8d07669
url="http://github.com/brimworks/lua-zlib"
pkgdesc='Simple streaming interface to zlib for Lua.'
arch=('i686' 'x86_64')
license=('MIT')
makedepends=('cmake' 'lua' 'lua51' 'zlib')
conflicts=('lua-lzlib')
source=("lua-zlib-$pkgver.zip::https://github.com/brimworks/lua-zlib/zipball/v$pkgver")
md5sums=('28ce556fccb2d364bc5392f63c6f89ee')

build() {
  cp -a $srcdir/brimworks-lua-zlib-${_gitver} $srcdir/brimworks-lua51-zlib-${_gitver}

  cd $srcdir/brimworks-lua-zlib-${_gitver}
  sed -i "s#share/lua/cmod#lib/lua/5.2#" CMakeLists.txt
  cmake -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_INSTALL_PREFIX=/usr .

  cd $srcdir/brimworks-lua51-zlib-${_gitver}
  sed -i "s#share/lua/cmod#lib/lua/5.1#" CMakeLists.txt
  cmake -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_INSTALL_PREFIX=/usr .
}

package_lua-zlib() {
  depends=('zlib' 'lua')

  cd $srcdir/brimworks-lua-zlib-${_gitver}
  make DESTDIR="$pkgdir" install
  install -D -m644 "README" "$pkgdir/usr/share/licenses/$pkgname/README"
}

package_lua51-zlib() {
  depends=('zlib' 'lua51')

  cd $srcdir/brimworks-lua51-zlib-${_gitver}
  make DESTDIR="$pkgdir" install
  install -D -m644 "README" "$pkgdir/usr/share/licenses/$pkgname/README"
}
